package com.love.usedcar.api.factory;

import com.love.common.core.web.domain.AjaxResult;
import com.love.usedcar.api.RemoteCityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

import static com.love.common.core.web.domain.AjaxResult.error;

public class RemoteCityFallbackFactory implements FallbackFactory<RemoteCityService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteCityFallbackFactory.class);

    @Override
    public RemoteCityService create(Throwable cause) {
        log.error("日志服务调用失败:{}", cause.getMessage());
        return new RemoteCityService()
        {
            @Override
            public AjaxResult selectProvinces(String source)
            {
                return AjaxResult.error("调用省份列表失败");
            }

            @Override
            public AjaxResult selectCitys(String source, String provinceCode) {
                return AjaxResult.error("调用城市列表失败");
            }

            @Override
            public AjaxResult cascader(String source) {
                return AjaxResult.error("调用城市列表失败");
            }
        };
    }
}
